package jmine.tec.scheduling.dao;

import static bancosys.tec.persist.hibernate.RestrictionsUtils.addRestrictionEq;
import static bancosys.tec.persist.hibernate.RestrictionsUtils.addRestrictionLike;

import java.util.List;

import jmine.tec.scheduling.domain.ScheduledTask;

import org.hibernate.Criteria;
import org.hibernate.criterion.MatchMode;

import bancosys.tec.persist.dao.BaseDAO;

/**
 * @author lundberg
 */
public class ScheduledTaskDAO extends BaseDAO<ScheduledTask> {

    /**
     * Finds all scheduled tasks similar to the given parameters
     * 
     * @param mnemonic mnemonic
     * @param description description
     * @param active active
     * @return List of ScheduledTask
     */
    public List<ScheduledTask> findLikeByMnemonicDescriptionActive(String mnemonic, String description, Boolean active) {
        Criteria criteria = this.createCriteria();
        addRestrictionLike(criteria, "mnemonic", mnemonic, MatchMode.ANYWHERE);
        addRestrictionLike(criteria, "description", description, MatchMode.ANYWHERE);
        addRestrictionEq(criteria, "active", active);
        return this.executeQuery(criteria);
    }

}
